﻿using System;
using System.Text;
using System.Diagnostics;

namespace GogTasks.Logic
{
    public static class Timing
    {
        private static StringBuilder _timingSb = new StringBuilder();
        public static string Text
        {
            get { return _timingSb.ToString(); }
        }
            
        private static long _lastMs;
        public static void Time(int p)
        {
            long msNow = Environment.TickCount;
            long diff = msNow - _lastMs;
            _lastMs = msNow;
            _timingSb.Append("[" + p + ":" + diff + "] ");
        }

        public static void Reset()
        {
            _timingSb = new StringBuilder();
            _lastMs = System.Environment.TickCount;
        }


        internal static void WriteToTrace()
        {
            Trace.WriteLine(_timingSb.ToString());
            _timingSb = new StringBuilder();
        }
    }
}